import request from '@/router/axios';

export const getList = (page, size, params) => {
  return request({
    url: '/base/specification/list',
    method: 'post',
    params: {
      ...params,
      page,
      size,
    }
  })
}
export const remove = (ids) => {
  return request({
    url: '/base/specification/delete',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
        specificationIdArray:ids
    }
  })
}

export const removeSelf = (id, parentId) => {
  return request({
    url: '/base/specification/deleteSelf',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      id,
      parentId,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/base/specification/addItem',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
		...row
	}
  })
}

//父属性新增
export const addParent = (row) => {
  return request({
    url: '/base/specification/addItemSelf',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: row
  })
}

//子属性新增
export const addChild = (specId, specpSequence, specpValue, specpType, specImageUrl) => {
  return request({
    url: '/base/specification/addItemChildSelf',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      specId,//父属性的id
      specpSequence,//排序名称
      specpValue,//规格详细值
      specpType,//规格类型
      specImageUrl,//图片路径
    }
  })
}

export const update = (row) => {
  return request({
    url: '/base/specification/editItem',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: row
  })
}

//父子属性编辑
export const updateParent = (row) => {
  return request({
    url: '/base/specification/editItemSelf',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: row
  })
}

export const changeStatus = (userId, status) => {
  return request({
    url: '/base/specification/changeStatus',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      userId,
      status
    }
  })
}